var a,
  t = require("../../@babel/runtime/helpers/defineProperty"),
  e = require("../../res/www.a9a.cn.js"),
  i = 2,
  n = !0,
  s = getApp(),
  r = wx.getStorageSync("COOK_U");
Page({
  data: {
    singlePage: !1,
    currentTab: 0,
    mask_class: "alpha0_100",
    ARR_index_nodata: !1,
    triggered: !0,
    loading_flag: !1,
    loading_ico_flag: !1,
    loading_str: "拼命加载中",
    backtop_flag_index: !1,
  },
  onLoad: function (a) {
    var t = this;
    s.get_config("_ZEAI").then(function (a) {
      t.setData({
        color: s._ZEAI.color,
        rgbcolor: e.c16_rgb(s._ZEAI.color),
        nikbg: s.WWW + "/res/m/img/nikbg.png",
      });
    }),
      s.get_navigationBarTopHeight(t),
      s.get_openid().then(function (a) {
        t.init();
      }),
      wx.getSystemInfo({
        success: function (a) {
          "singlePage" == a.mode
            ? t.init()
            : s.get_openid().then(function (a) {
                t.init();
              });
        },
      });
  },
  reset_par: function () {
    this.setData({
      triggered: !1,
      loading_flag: !1,
      loading_str: "拼命加载中",
      ARR_index: [],
      ARR_index_nodata: !1,
    }),
      (i = 2),
      (s.globalData.hn_par = {}),
      (s.globalData.index_par = {});
  },
  onShow: function () {
    var t = this;
    if (e.empty(s.globalData.hn_par))
      if (e.empty(s.globalData.index_par)) {
        if (((r = wx.getStorageSync("COOK_U")), s.empty(r))) return;
        s.ajax({
          url: "index4.php",
          data: { submitok: "onshow", openid: r.openid, unionid: r.unionid },
          success: function (a) {
            if (1 == a.flag && a.cook_flag != r.flag)
              return (
                (r.flag = a.cook_flag),
                wx.setStorageSync("COOK_U", r),
                void t.upFn()
              );
          },
        });
      } else {
        switch (((a = s.globalData.index_par), this.reset_par(), a.sokind)) {
          case "gps":
            t.setData({ currentTab: 1 });
            break;
          case "match":
            t.setData({ currentTab: 2 });
            break;
          case "ext":
            t.setData({ currentTab: a.sex });
        }
        t.init();
      }
    else
      (a = s.globalData.hn_par),
        this.reset_par(),
        this.setData({ currentTab: 0 }),
        t.init();
  },
  topbarFn: function (t) {
    var e = t.currentTarget.dataset.idx;
    if (
      (this.setData({ currentTab: e }),
      this.reset_par(),
      1 == this.data.iModuleU)
    )
      switch (e) {
        case 0:
          a = {};
          break;
        case 1:
          a = { sokind: "gps" };
          break;
        case 2:
          a = { sokind: "match" };
      }
    else
      switch (e) {
        case 0:
          a = {};
          break;
        case 1:
          a = { sokind: "ext", sex: 1 };
          break;
        case 2:
          a = { sokind: "ext", sex: 2 };
      }
    this.init();
  },
  init: function () {
    var i = this;
    wx.showLoading({ title: "玩命加载中...", mask: !0 }), (n = !1);
    var o = {
      submitok: "index",
      openid: (r = wx.getStorageSync("COOK_U")).openid,
      showtype: this.data.showtype,
    };
    e.empty(a) ||
      (o = JSON.parse(
        (JSON.stringify(o) + JSON.stringify(a)).replace(/}{/, ",")
      )),
      this.data.currentTab > 0 &&
        this.setData({ pxclass: "", sobox: !1, sokind: "" }),
      s.ajax({
        url: "user.php",
        data: o,
        success: function (a) {
          if (1 == a.flag) {
            var s;
            if (
              (1 == a.iModuleU
                ? i.setData({ topbar: ["推荐", "附近的", "匹配我"] })
                : i.setData({ topbar: ["推荐", "男嘉宾", "女嘉宾"] }),
              console.log(a.rz_dataARR),
              0 == a.LIST.length || e.empty(a.LIST))
            )
              i.setData({
                iModuleU: a.iModuleU,
                showtype: a.showtype,
                rz_dataARR: a.rz_dataARR,
                SHARE: a.SHARE,
                ARR_index: a.LIST,
                ARR_index_nodata: !0,
                pxSO: a.pxSO,
                SO: a.SO,
                areaidARR: a.areaidARR,
                area2idARR: a.area2idARR,
              });
            else
              i.setData(
                ((s = {
                  iModuleU: a.iModuleU,
                  showtype: a.showtype,
                  rz_dataARR: a.rz_dataARR,
                  SHARE: a.SHARE,
                }),
                t(s, "ARR_index[0]", a.LIST),
                t(s, "ARR_index_nodata", !1),
                t(s, "pxSO", a.pxSO),
                t(s, "SO", a.SO),
                t(s, "areaidARR", a.areaidARR),
                t(s, "area2idARR", a.area2idARR),
                s)
              );
            var r = e.get_tabbar_index("my_msg");
            a.btmnewnum > 0
              ? wx.setTabBarBadge({ index: r, text: a.btmnewnum })
              : wx.removeTabBarBadge({ index: r });
          } else (a.this = i), (a.url = "no"), e.sorry(a);
          wx.hideLoading(), (n = !0);
        },
      });
  },
  showtypeFn: function () {
    this.setData({ showtype_box: !0, mask_class: "alpha0_100" });
  },
  showtype_setFn: function (a) {
    var t = a.currentTarget.dataset.value;
    this.setData({ showtype: t });
  },
  showtype_box_closeFn: function (a) {
    var e = this,
      i = a.currentTarget.dataset.maskid;
    this.setData({ mask_class: "alpha100_0" }),
      setTimeout(function () {
        e.setData(t({}, i, !1));
      }, 500);
  },
  mask_closeFn: function (a) {
    var e = a.currentTarget.dataset.maskid;
    this.setData(t({ mask_class: "alpha100_0" }, e, !1)), this.back();
  },
  gpsFn: function () {
    var t = this;
    wx.getFuzzyLocation({
      success: function (e) {
        s.ajax({
          url: "user.php",
          data: {
            submitok: "gps_save",
            longitude: e.longitude,
            latitude: e.latitude,
            openid: r.openid,
          },
          success: function (e) {
            1 == e.flag
              ? (t.setData({ div_gps: !1, currentTab: 1 }),
                t.reset_par(),
                (a = { sokind: "gps" }),
                t.init())
              : wx.showToast({ title: e.msg, icon: "none", mask: !0 });
          },
        });
      },
      fail: function (a) {
        "getFuzzyLocation:fail system permission denied" == a.errMsg
          ? wx.showModal({
              content: "亲，请开启手机定位再来操作哦",
              confirmColor: t.data.color,
              confirmText: "朕知道了",
              showCancel: !1,
              success: function (a) {},
            })
          : wx.showModal({
              content: "请设置：位置信息 > 使用小程序时允许",
              success: function (a) {
                a.confirm &&
                  wx.openSetting({
                    success: function (a) {
                      console.log(a.authSetting),
                        (a.authSetting = {
                          "scope.userInfo": !0,
                          "scope.userLocation": !0,
                        });
                    },
                  });
              },
            });
      },
    });
  },
  dataFn: function () {
    wx.navigateTo({ url: "../reg/reg" });
  },
  setloading: function (a, t) {
    "start" == a
      ? this.setData({ loading_flag: !0, loading_ico_flag: !0, loading_str: t })
      : this.setData({
          loading_flag: !1,
          loading_ico_flag: !1,
          loading_str: t,
        });
  },
  upFn: function (t) {
    var e = this;
    wx.vibrateShort({ type: "heavy" }),
      (s.globalData.hn_par = {}),
      setTimeout(function () {
        e.setData({
          triggered: !1,
          loading_flag: !1,
          loading_str: "拼命加载中",
          ARR_index: [],
          ARR_index_nodata: !1,
          guestloadP_flag: !1,
          sokind: "",
          currentTab: 0,
        }),
          (i = 2),
          (a = {}),
          e.init();
      }, 500);
  },
  btmFn: function (o) {
    var d = this.data.ARR_index,
      c = this;
    if (n) {
      (n = !1), c.setloading("start", "玩命加载中");
      var l = { submitok: "index", p: i, openid: r.openid };
      e.empty(a) ||
        (l = JSON.parse(
          (JSON.stringify(l) + JSON.stringify(a)).replace(/}{/, ",")
        )),
        s.ajax({
          url: "user.php",
          data: l,
          success: function (a) {
            if (i > a.guestloadP && a.guestloadP > 0 && 1 != a.iflogin)
              return (
                c.setloading("stop", "请登录/注册"),
                (n = !1),
                void c.setData({ guestloadP_flag: !0, iflogin: a.iflogin })
              );
            if (1 == a.flag) {
              var e = d.length;
              if (a.LIST.length < 1)
                return c.setloading("end", "已全部加载完毕"), void (n = !1);
              c.setData(t({}, "ARR_index[" + e + "]", a.LIST)),
                (i += 1),
                (n = !0);
            } else wx.showToast({ title: a.msg, icon: "none", mask: !0 });
            c.setloading("end", "上拉加载更多");
          },
        });
    }
  },
  backtopFn: function (a) {
    var e = "scrolltopNum_" + a.currentTarget.dataset.id;
    this.setData(t({}, e, 0));
  },
  binnd_scroll_index: function (a) {
    a.detail.scrollTop > 100
      ? this.setData({ backtop_flag_index: !0 })
      : this.setData({ backtop_flag_index: !1 });
  },
  pxFn: function () {
    var a, t;
    "ed" == this.data.pxclass ? ((t = !1), (a = "")) : ((a = "ed"), (t = !0)),
      this.setData({ pxclass: a, sobox: t });
  },
  souboxFn: function (t) {
    var e = t.currentTarget.dataset.sokind;
    (a = { sokind: e }),
      this.reset_par(),
      this.setData({ sokind: e, currentTab: 0 }),
      this.init();
  },
  px_ageFn: function (i) {
    var n,
      s = i.detail.value;
    if (s[0] > s[1])
      return wx.showToast({ title: "必须左小右大哦", icon: "none" }), !1;
    var r = this.data.pxSO.age.arr[0],
      o = e.idx_iv(s, r),
      d = o[0],
      c = (o[1], d.split(","));
    this.reset_par(),
      this.setData((t((n = {}), "pxSO.age.def", c), t(n, "currentTab", 0), n)),
      (a = { sokind: "ext", age: d }),
      this.init();
  },
  px_heighFn: function (i) {
    var n,
      s = i.detail.value;
    if (s[0] > s[1])
      return wx.showToast({ title: "必须左小右大哦", icon: "none" }), !1;
    var r = this.data.pxSO.heigh.arr[0],
      o = e.idx_iv(s, r),
      d = o[0],
      c = (o[1], d.split(","));
    this.reset_par(),
      this.setData(
        (t((n = {}), "pxSO.heigh.def", c), t(n, "currentTab", 0), n)
      ),
      (a = { sokind: "ext", heigh: d }),
      this.init();
  },
  moreFn: function () {
    var a;
    (a = "ed" == this.data.somoreclass ? "" : "ed"),
      this.setData({
        index_so_flag: !0,
        index_so_mask_class: "alpha0_100",
        index_so_box_class: "div_leftAnm1",
        somoreclass: a,
      });
  },
  index_so_closeFn: function () {
    var a = this;
    this.setData({
      index_so_mask_class: "alpha100_0",
      index_so_box_class: "div_leftAnm2",
      somoreclass: "",
    }),
      setTimeout(function () {
        a.setData({ index_so_flag: !1 });
      }, 400);
  },
  rangFn: function (a) {
    a.currentTarget.dataset.f;
    var i,
      n = a.currentTarget.dataset.index,
      s = a.detail.value;
    if (s[0] > s[1])
      wx.showToast({ title: "请选择左小右大范围", icon: "none", mask: !0 });
    else {
      var r = e.idx_iv(s, this.data.SO[n].arr.arr[0]);
      this.setData(
        (t((i = {}), "SO[" + n + "].i", r[0]), t(i, "SO[" + n + "].v", r[1]), i)
      );
    }
  },
  index_SO_onoffFn: function (a) {
    var e,
      i = a.currentTarget.dataset.index;
    (e = "on" == this.data.SO[i].onoff ? "off" : "on"),
      this.setData(t({}, "SO[" + i + "].onoff", e));
  },
  index_SO_liFn: function (a) {
    if ("vip" != a.currentTarget.dataset.auth) {
      var i,
        n = a.currentTarget.dataset.idx,
        s = a.currentTarget.dataset.i,
        r = a.currentTarget.dataset.fkind,
        o = this.data.SO[n].i;
      (i = e.empty(o)
        ? s
        : "checkbox" == r
        ? e.indexOf(o, s)
          ? (i = e.json_remove(o, s)).join(",")
          : o + "," + s
        : s),
        0 == s && (i = 0),
        this.setData(t({}, "SO[" + n + "].i", i));
    } else this.vipFn();
  },
  index_SO_submitFn: function (t) {
    ((a = t.detail.value).keyword = this.data.keyword),
      this.reset_par(),
      this.index_so_closeFn(),
      this.setData({ currentTab: 0 }),
      this.init();
  },
  index_SO_resetFn: function (a) {
    var e = this.data.SO;
    for (var i in e) {
      var n;
      this.setData(
        (t((n = {}), "SO[" + i + "].i", 0), t(n, "SO[" + i + "].v", ""), n)
      );
    }
    this.setData({ keyword: "" });
  },
  vipFn: function () {
    s.chklogin().then(function (a) {
      a
        ? wx.navigateTo({ url: "../my_vip/my_vip" })
        : wx.navigateTo({ url: "../login/login" });
    });
  },
  areaidFn: function (a) {
    for (
      var i,
        n = a.currentTarget.dataset.kind,
        s = (a.currentTarget.dataset.f, a.detail.value),
        r = a.currentTarget.dataset.idx,
        o = [],
        d = 0;
      d < s.length;
      d++
    )
      s[d] > 0 && o.push(s[d] - 1);
    if (((s = o), "hj" == n)) var c = e.areaGetTtitle(s, this.data.area2idARR);
    else c = e.areaGetTtitle(s, this.data.areaidARR);
    var l = c[0],
      u = c[1];
    this.setData(
      (t((i = {}), "SO[" + r + "].i", l), t(i, "SO[" + r + "].v", u), i)
    );
  },
  areaidChangeFn: function (a) {
    var i,
      n = a.currentTarget.dataset.kind,
      s = a.detail.column,
      r = a.detail.value,
      o = a.currentTarget.dataset.idx,
      d = "hj" == n ? 4 : parseInt(this.data.SO[o].arealeval),
      c = { def: this.data.SO[o].arr.def, idx: this.data.SO[o].arr.idx };
    if ("hj" == n)
      var l = this.data.area2idARR.ARR1,
        u = this.data.area2idARR.ARR2,
        g = this.data.area2idARR.ARR3,
        h = this.data.area2idARR.ARR4;
    else
      (l = this.data.areaidARR.ARR1),
        (u = this.data.areaidARR.ARR2),
        (g = this.data.areaidARR.ARR3),
        (h = this.data.areaidARR.ARR4);
    var f,
      _,
      x,
      p = [{ i: "0", v: "不限", f: "0" }],
      R = l,
      b = [],
      v = [],
      k = [];
    switch (((R = p.concat(R)), s)) {
      case 0:
        if (0 == r)
          switch (
            ((c.def[0] = R),
            d >= 2 && (c.def[1] = p),
            d >= 3 && (c.def[2] = p),
            d >= 4 && (c.def[3] = p),
            d)
          ) {
            case 1:
              c.idx = [0];
              break;
            case 2:
              c.idx = [0, 0];
              break;
            case 3:
              c.idx = [0, 0, 0];
              break;
            case 4:
              c.idx = [0, 0, 0, 0];
          }
        else
          switch (((f = l[r - 1].i), d)) {
            case 1:
              (c.def = [R]), (c.idx = [r]);
              break;
            case 2:
              (b = p.concat(e.areaNEW(f, u))),
                (c.def = [R, b]),
                (c.idx = [r, 0]);
              break;
            case 3:
              (b = p.concat(e.areaNEW(f, u))),
                (c.def = [R, b, p]),
                (c.idx = [r, 0, 0]);
              break;
            case 4:
              (b = p.concat(e.areaNEW(f, u))),
                (c.def = [R, b, p, p]),
                (c.idx = [r, 0, 0, 0]);
          }
        break;
      case 1:
        if (0 == r)
          d >= 3 && (c.def[2] = p),
            d >= 4 && (c.def[3] = p),
            d >= 2 && (c.idx[1] = r),
            d >= 3 && (c.idx[2] = 0),
            d >= 4 && (c.idx[3] = 0);
        else
          switch (d) {
            case 2:
              c.idx[1] = r;
              break;
            case 3:
              (f = l[c.idx[0] - 1].i),
                (_ = (b = p.concat(e.areaNEW(f, u)))[r].i),
                (v = p.concat(e.areaNEW(_, g))),
                (c.def[2] = v),
                (c.idx[1] = r),
                (c.idx[2] = 0);
              break;
            case 4:
              (f = l[c.idx[0] - 1].i),
                (_ = (b = p.concat(e.areaNEW(f, u)))[r].i),
                (v = p.concat(e.areaNEW(_, g))),
                (c.def[2] = v),
                (c.def[3] = p),
                (c.idx[1] = r),
                (c.idx[2] = 0),
                (c.idx[3] = 0);
          }
        break;
      case 2:
        if (0 == r)
          d >= 4 && (c.def[3] = p),
            d >= 3 && (c.idx[2] = r),
            d >= 4 && (c.idx[3] = 0);
        else
          switch (d) {
            case 3:
              c.idx[2] = r;
              break;
            case 4:
              (f = l[c.idx[0] - 1].i),
                (_ = (b = p.concat(e.areaNEW(f, u)))[c.idx[1]].i),
                (x = (v = p.concat(e.areaNEW(_, g)))[r].i),
                (k = p.concat(e.areaNEW(x, h))),
                (c.def[3] = k),
                (c.idx[2] = r),
                (c.idx[3] = 0);
          }
        break;
      case 3:
        d >= 4 && (c.idx[3] = r);
    }
    this.setData(
      (t((i = {}), "SO[" + o + "].arr.def", c.def),
      t(i, "SO[" + o + "].arr.idx", c.idx),
      i)
    );
  },
  index_SO_uid_submitFn: function (t) {
    (a = t.detail.value),
      this.setData({ keyword: a.keyword }),
      this.index_so_closeFn(),
      this.reset_par(),
      this.setData({ currentTab: 0 }),
      this.init();
  },
  index_SO_uid_submitFn2: function (t) {
    var e = t.detail.value;
    this.index_so_closeFn(),
      this.reset_par(),
      (a = { sokind: "keyword", keyword: e }),
      this.setData({ currentTab: 0 }),
      this.init();
  },
  index_SO_uid_bindblurFn: function (a) {
    var t = a.detail.value;
    this.setData({ keyword: t });
  },
  getPhoneNumber: function (a) {
    s.getPhoneNumber({ e: a, url: "../reg/reg", urlkind: "navigateTo" });
  },
  back: function () {
    this.setData({ div_login: !1, currentTab: 0 }),
      this.reset_par(),
      (a = { sokind: "" }),
      this.init();
  },
  onShareAppMessage: function (a) {
    return {
      imageUrl: this.data.SHARE.imgurl,
      title: this.data.SHARE.title,
      path: "/pages/index/index4",
    };
  },
  onShareTimeline: function () {
    return {
      imageUrl: this.data.SHARE.imgurl,
      title: this.data.SHARE.title,
      query: "",
      path: "/pages/index/index4",
    };
  },
  emptyFn: function () {},
  ifagreeFn: function (a) {
    1 == a.detail.value
      ? this.setData({ ifagree: !0 })
      : this.setData({ ifagree: !1 });
  },
  ifagree_passFn: function () {
    wx.showToast({
      title: "请先点击同意《用户协议》和《隐私条款》",
      icon: "none",
      mask: !0,
      duration: 3e3,
    });
  },
  privacy_agree: function (a) {
    console.log("agree");
  },
  privacy_disagree: function (a) {
    console.log("disagree"), wx.exitMiniProgram();
  },
});
